package com.nwpu.coursesupport.mapper;

import java.util.List;

import org.apache.ibatis.session.RowBounds;

import com.nwpu.coursesupport.criteria.SearchCriteria;
import com.nwpu.coursesupport.entity.bean.BaseEntity;


public interface BaseMapper<E extends BaseEntity> {

	/**
	 * Find an entity by id
	 * 
	 * @param id the id to find
	 * @return
	 */
	public E findById(Integer id);
	
	/**
	 * Find entities with the specified search criteria
	 * 
	 * @param searchCriteria the search criteria
	 * @return
	 */
	public List<E> find(SearchCriteria searchCriteria);
	
	public int count(SearchCriteria searchCriteria);
	
	/**
	 * Find entities with the specified search criteria and bounds
	 * 
	 * @param searchCriteria the search criteria
	 * @param bounds the row bounds
	 * @return
	 */
	public List<E> find(SearchCriteria searchCriteria, RowBounds bounds);
	
	/**
	 * Save an entity
	 * 
	 * @param entity the entity
	 * @return
	 */
	public boolean save(E entity);
	
	/**
	 * Update an entity
	 * 
	 * @param entity the entity
	 * @return
	 */
	public boolean update(E entity);
	
	/**
	 * Delete an entity by id
	 * 
	 * @param id the id to delete
	 * @return
	 */
	public boolean delete(Integer id);
	
	/**
	 * Batch deletes entities by id
	 * 
	 * @param ids the ids to delete
	 * @return
	 */
	public boolean batchDelete(List<Integer> ids);
}

